//
//  FirstPageURLRequest.m
//  BSLCar
//
//  Created by dlios on 15/5/22.
//  Copyright (c) 2015年 lyz. All rights reserved.
//

#import "FirstPageURLRequest.h"

@implementation FirstPageURLRequest

+ (NSArray *)getParserResult {
    NSMutableArray *rootArray = [NSMutableArray array];
    NSMutableArray *rAr = [NSMutableArray array];
    NSMutableArray *arr = [NSMutableArray array];

    NSString *string = @"http://wz.qichecdn.com/ashx/getnewsindex.ashx?&token=2&platform=2&version=3.9.2&qd=zhuselectedapp";
    string = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:string];
    NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:20];
    NSError *error = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
    if (!error) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *dic2 = [dic objectForKey:@"result"];
        NSArray *array = [dic2 objectForKey:@"items"];
        for (NSDictionary *dic3 in array) {
            NSString *string = [dic3 objectForKey:@"picurl"];
            [rootArray addObject:string];
            NSString *str = [dic3 objectForKey:@"newsurl"];
            NSString *strr = [dic3 objectForKey:@"title"];
            [rAr addObject:str];
            [arr addObject:strr];
        }
        [rAr addObject:arr];
        [rootArray addObject:rAr];
    }
    return rootArray;
}
@end
